<template>
  <div v-cloak class="shop-info">
    <div class="shop-top">
      <img v-cloak :src="shop.logo">
      <span v-cloak class="title">{{shop.name}}</span>
    </div>
    <div class="shop-middle">
      <div class="shop-middle-item shop-middle-left">
        <div class="info-sells">
          <div v-cloak class="sells-count" style="{fontSize:5.625vw;}">
            {{sellCountFilter()}}
          </div>
          <div class="sells-text">总销量</div>
        </div>
        <div class="info-goods">
          <div v-cloak class="goods-count">
            {{shop.goodsCount}}
          </div>
          <div class="goods-text">全部宝贝</div>
        </div>
      </div>
      <div class="shop-middle-item shop-middle-right">
        <table>
          <tr v-for="(item, index) in shop.score" :key="index">
            <td>{{item.name}}</td>
            <td class="score" :class="{'score-better': item.isBetter}">{{item.score}}</td>
            <td class="better" :class="{'better-more': item.isBetter}"><span>{{item.isBetter ? '高':'低'}}</span></td>
          </tr>
        </table>
      </div>
    </div>
    <div class="shop-bottom">
      <div class="enter-shop">进店逛逛</div>
    </div>
  </div>
</template>

<script>
	export default {
		name: "DetailShopInfo",
    props: {
		  shop: {
		    type: Object,
        default() {
          return {}
        }
      }
    },
    mounted() {
      this.sellCountFilter()
    },
    methods:{
      sellCountFilter(){
        if (this.shop.sells < 10000) return this.shop.sells;
        return (this.shop.sells/10000).toFixed(1) + 'W'
      }
    }
	}
</script>

<style scoped>
  [v-cloak]{
    display: none;
  }
  .shop-info {
    padding: 7.8125vw 2.5vw;
    border-bottom: 1.5625vw solid #f2f5f8;
  }
  .shop-top {
    line-height: 14.0625vw;
    /* 让元素垂直中心对齐 */
    display: flex;
    align-items: center;
  }
  .shop-top img {
    width: 14.0625vw;
    height: 14.0625vw;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.1);
  }
  .shop-top .title {
    margin-left: 3.125vw;
    vertical-align: center;
  }
  .shop-middle {
    margin-top: 4.6875vw;
    display: flex;
    align-items: center;
  }
  .shop-middle-item {
    flex: 1;
  }
  .shop-middle-left {
    display: flex;
    justify-content: space-evenly;
    color: #333;
    text-align: center;
    border-right: 1px solid rgba(0,0,0,.1);
  }
  .sells-count, .goods-count {
    font-size: 5.625vw;
  }
  .sells-text, .goods-text {
    margin-top: 3.125vw;
    font-size: 3.75vw;
  }
  .shop-middle-right {
    font-size: 4.0625vw;
    color: #333;
  }
  .shop-middle-right table {
    width: 37.5vw;
    margin-left: 9.375vw;
  }
  .shop-middle-right table td {
    padding: 1.5625vw 0;
  }
  .shop-middle-right .score {
    color: #5ea732;
  }
  .shop-middle-right .score-better {
    color: #f13e3a;
  }
  .shop-middle-right .better span {
    background-color: #5ea732;
    color: #fff;
    text-align: center;
  }
  .shop-middle-right .better-more span {
    background-color: #f13e3a;
  }
  .shop-bottom {
    text-align: center;
    margin-top: 3.125vw;
  }
  .enter-shop {
    display: inline-block;
    font-size: 4.375vw;
    background-color: #f2f5f8;
    width: 46.875vw;
    height: 9.375vw;
    text-align: center;
    line-height: 9.375vw;
    border-radius: 3.125vw;
  }
</style>